<!--
 * @Author: liangzhuo liangzhuo@chzu.com
 * @Date: 2022-05-07 10:25:10
 * @LastEditors: liangzhuo liangzhuo@chzu.com
 * @LastEditTime: 2022-05-07 16:30:04
 * @FilePath: \ruoyi-ui\src\views\archives\dataDetails\index.vue
 * @Description: 建立电子档案---数据详情
-->
<template>
  <div class="app-container">
    <!-- 顶部卡牌数据 -->
    <div class="top_card">
      <div class="card_">
        <el-card class="box_card">
          <el-row :gutter="20">
            <el-col :span="12" class="grid-content">
              <p style="font-weight: 1000;">牲畜总数</p>
              <div class="card_text">
                7829 &nbsp; 件
              </div>
            </el-col>
            <el-col :span="12" class="grid-content"><chartTotalNumVue/></el-col>
          </el-row>
        </el-card>
      </div>
      <div class="card_">
        <el-card class="box_card">
          <el-row :gutter="20">
            <el-col :span="12" class="grid-content">
              <p style="font-weight: 1000;">管理</p>
              <div class="card_text">
                7 &nbsp; 个
              </div>
            </el-col>
            <el-col :span="12" class="grid-content"><chartManage/></el-col>
          </el-row>
        </el-card>
      </div>
    </div>
   <!-- 中间的两个图表 -->
   <div class="center_chart">
     <div>
       <dataNumOfMonth/>
     </div>
     <div>
       <typeOfPig/>
     </div>
   </div>
   <!-- 底部的表格 -->
   <div class="buttom_form">
      <div class="form_buttom">
        <el-row :gutter="20">
          <el-col :span="11" :offset="1"><span style="line-height: 40px; font-size: 20px;">数据详情</span></el-col>
          <el-col :span="3" :offset="9">
            <el-button><i class="el-icon-upload2"/>&nbsp;&nbsp;数据导出</el-button> 
          </el-col>
        </el-row>
      </div>
      <div class="form_data">
        <el-table :data="pigList" style="width: 100%" max-height="250" >
        
          <el-table-column fixed prop="id" label="ID" width="150" />
          <el-table-column fixed prop="earTag" label="耳标" width="150" />
          <el-table-column prop="pigsty" label="猪舍号" width="120" />
          <el-table-column prop="pnumber" label="母猪编号" width="120" />
        
          <el-table-column prop="birthWeight" label="出生体重" width="120" />
     
          <el-table-column prop="ptype" label="品种" width="120" />
         
          <el-table-column prop="breederName" label="饲养员" width="120" />
         <el-table-column prop="birthday" label="出生日期" width="200" />
         <el-table-column  label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:post:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:post:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
        </el-table>
      </div>
      <div class="form_page">
       <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"

      >
      </pagination>




      </div>

       <!-- 修改猪信息配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px"  >
        <el-row>
          <el-col :span="12">
            <el-form-item label="耳标" prop="earTag">
              <el-input v-model="form.earTag" placeholder="请输入用户昵称" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="编号" prop="pnumber">
              <el-input v-model="form.pnumber" placeholder="请输入用户昵称" maxlength="30" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="品种" prop="ptype">
              <el-input v-model="form.ptype" placeholder="请输入手机号码" maxlength="11" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="昵称" prop="nickName">
              <el-input v-model="form.nickName" placeholder="请输入邮箱" maxlength="50" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item  label="猪舍号" prop="pigsty">
              <el-input v-model="form.pigsty" placeholder="请输入用户名称" maxlength="30" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item  label="出生体重" prop="birthWeight">
              <el-input v-model="form.birthWeight" placeholder="请输入用户密码"  maxlength="20" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item  label="性别" prop="sex">
              <el-input v-model="form.sex" placeholder="请输入用户密码"  maxlength="20" />
            </el-form-item>
          </el-col>
       <el-col :span="12">
            <el-form-item  label="是否受疫" prop="hasImmune">
              <el-input v-model="form.hasImmune" placeholder="请输入用户密码"  maxlength="20" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
        <el-col :span="12">
            <el-form-item  label="饲养员" prop="breederName">
              <el-input v-model="form.breederName" placeholder="请输入用户名称" maxlength="30" />
            </el-form-item>
          </el-col>
        <el-col :span="12">
            <el-form-item  label="出生日期" prop="birthday">
          
         <el-date-picker
       value-format="yyyy-MM-dd HH:mm:ss"
      v-model="form.birthday"
      type="datetime"
      placeholder="选择日期时间">
    </el-date-picker>
          
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="图片">

          
             
     

            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
   </div>
  </div>
</template>

<script>
import { listPig,delPig, updatePig} from "@/api/system/archives/dpig";
import chartTotalNumVue from "@/components/DataDetails/chartTotalNum";
import chartManage from "@/components/DataDetails/chartManage";
import dataNumOfMonth from "@/components/DataDetails/dataNumOfMonth";
import typeOfPig from "@/components/DataDetails/typeOfPig";
export default {
  name: 'RuoyiUiIndex',
  components:{chartTotalNumVue, chartManage, dataNumOfMonth, typeOfPig},
  data() {
    return {
     
     msgFormSon:"",

      open:false,

       title: "",
      pigList:[],

      adoptList:[],

      currentPage2: 5,

       total:0,

       form:{},

        queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
       // 表单校验
      rules: {
       adoptPhone: [
          { required: true, message: "联系方式不能为空", trigger: "blur" }
        ],
        earTag: [
          { required: true, message: "耳标号不能为空", trigger: "blur" }
        ],
      hasVerify: [
          { required: true, message: "审核状态不能为空", trigger: "blur" }
        ]
      }
    };
  },

  created(){
this.getList();

  },



  methods: {

    reset() {
      this.form = {
        postId: undefined,
        postCode: undefined,
        postName: undefined,
        postSort: 0,
        status: "0",
        remark: undefined
      };
      this.resetForm("form");
    },

   getList() {
      this.loading = true;
      listPig(this.queryParams).then(response => {
     console.log(response);
       this.pigList=response.rows;
        this.total=response.total;
        }
      );
    },


    /** 删除按钮操作 */
    handleDelete(row) {
      const pigId = row.id;
      console.log(pigId);
      this.$modal.confirm('是否确认删除编号为"' + row.earTag + '"的数据项？').then(function() {
        return delPig(pigId);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
       /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
     this.queryParams.id = row.id || this.ids
     listPig(this.queryParams).then(response => {
     
      console.log(response.rows[0])
        this.form =response.rows[0];
         
        this.open = true;
        this.title = "修改种猪数据";
      });
    },
     /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          console.log(this.form.id);
          if (this.form.id != undefined) {
            updatePig(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.queryParams.id=0;
              this.getList();
            });
          } 
        }
      });
    },
      // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
   
  },
   
};
</script>

<style lang="scss" scoped>
.top_card {
  width: 100%;
  height: 180px;
  display: flex;
  .card_ {
    flex: 1;
    width: 200px;
    margin-left: 50px;
    margin-right: 50px;
    display: flex;
    .box_card {
      width: 100%;
      height: 100%;
      .grid-content {
        height: 150px;
        .card_text {
          text-align: center;
          font-size: 20px;
          font-weight: 1000;
        }
      }
    }
  }
}
.center_chart {
  width: 100%;
  height: 250px;
  margin-top: 10px;
  display: flex;

  & > div {
    flex: 1;
    margin: 0 20px;
  }
}

.buttom_form {
  width: 100%;
  height: 340px;
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  // background-color: antiquewhite;
  .form_buttom {
    flex: 1.5;
    // background-color: aqua;
  }
  .form_data {
    flex: 10;
    // background-color: palegoldenrod;
  }
  .form_page {
    flex: 1.5;
    text-align: right;
    // background-color: aqua;
  }
}
</style>